﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsFunctionalAreaDAL
/// </summary>
public class clsFunctionalAreaDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsFunctionalAreaDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public List<IN_TB_FUNCTIONAL_AREA> GetAllFunctionalAreas()
    {
        try
        {
            List<IN_TB_FUNCTIONAL_AREA> objIN_TB_FUNCTIONAL_AREA = new List<IN_TB_FUNCTIONAL_AREA>();
            objIN_TB_FUNCTIONAL_AREA = (from obj in objInstantNaukriDataContextDataContext.IN_TB_FUNCTIONAL_AREAs
                                        select obj).ToList();
            return objIN_TB_FUNCTIONAL_AREA;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_FUNCTIONAL_AREA GetAllFunctionalAreaById(int Id)
    {
        try
        {
            IN_TB_FUNCTIONAL_AREA objIN_TB_FUNCTIONAL_AREA = new IN_TB_FUNCTIONAL_AREA();
            objIN_TB_FUNCTIONAL_AREA = (from obj in objInstantNaukriDataContextDataContext.IN_TB_FUNCTIONAL_AREAs
                                        where obj.ID == Id
                                        select obj).SingleOrDefault();
            return objIN_TB_FUNCTIONAL_AREA;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveFunctionalMst(IN_TB_FUNCTIONAL_AREA objIN_TB_FUNCTIONAL_AREA)
    {
        try
        {
            IN_TB_FUNCTIONAL_AREA objIN_TB_FUNCTIONAL_AREAD = new IN_TB_FUNCTIONAL_AREA();
            objIN_TB_FUNCTIONAL_AREAD = (from obj in objInstantNaukriDataContextDataContext.IN_TB_FUNCTIONAL_AREAs
                                         where obj.ID == objIN_TB_FUNCTIONAL_AREA.ID
                                         select obj).SingleOrDefault();
            if (objIN_TB_FUNCTIONAL_AREAD != null)
            {
                objIN_TB_FUNCTIONAL_AREAD.ID = objIN_TB_FUNCTIONAL_AREA.ID;
                objIN_TB_FUNCTIONAL_AREAD.FUNCTIONAL_AREA = objIN_TB_FUNCTIONAL_AREA.FUNCTIONAL_AREA;
                objIN_TB_FUNCTIONAL_AREAD.CREATED_BY = objIN_TB_FUNCTIONAL_AREA.CREATED_BY;
                objIN_TB_FUNCTIONAL_AREAD.CREATED_ON = objIN_TB_FUNCTIONAL_AREA.CREATED_ON;
                objIN_TB_FUNCTIONAL_AREAD.MODIFIED_BY = objIN_TB_FUNCTIONAL_AREA.MODIFIED_BY;
                objIN_TB_FUNCTIONAL_AREAD.MODIFIED_ON = objIN_TB_FUNCTIONAL_AREA.MODIFIED_ON;

                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_FUNCTIONAL_AREA.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_FUNCTIONAL_AREAs.InsertOnSubmit(objIN_TB_FUNCTIONAL_AREA);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_FUNCTIONAL_AREA.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
    public void DeleteFUNCTIONALAREA(int Functional_Id)
    {
        try
        {
            IN_TB_FUNCTIONAL_AREA objIN_TB_FUNCTIONAL_AREA = new IN_TB_FUNCTIONAL_AREA();
            objIN_TB_FUNCTIONAL_AREA = (from obj in objInstantNaukriDataContextDataContext.IN_TB_FUNCTIONAL_AREAs
                                        where obj.ID == Functional_Id
                                        select obj).SingleOrDefault();
            if (objIN_TB_FUNCTIONAL_AREA != null)
            {
                objInstantNaukriDataContextDataContext.IN_TB_FUNCTIONAL_AREAs.DeleteOnSubmit(objIN_TB_FUNCTIONAL_AREA);
                objInstantNaukriDataContextDataContext.SubmitChanges();
            }

        }
        catch (Exception)
        {

            throw;
        }
    }
}
